package com.example.origin.resttemplate.controller;

import com.example.origin.resttemplate.util.ConcurrentUtil;
import com.example.origin.resttemplate.util.RestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author yutao.zhang
 * @create 2023-07-27 9:47
 **/
@Slf4j
@RestController
public class DemoContoller {


    @Autowired
    private RestTemplate restTemplate;


    @GetMapping(value = "users")
    public ResponseEntity<Object> users() {
        return RestUtil.restGet(restTemplate, "http://localhost:7060/users");
    }


    @GetMapping("test")
    public void test() {
        ConcurrentUtil.concurrenTest(i -> {
            RestUtil.restGet(restTemplate, "http://localhost:9911/acceptRequest?num=" + i);
        }, 100);
    }


}
